//
//  RMMChooseFuWuHeadView.m
//  Romomo
//
//  Created by puman on 2017/2/8.
//  Copyright © 2017年 mazegong. All rights reserved.
//

#import "RMMChooseFuWuHeadView.h"

@implementation RMMChooseFuWuHeadView

- (instancetype)initWithFrame:(CGRect)frame array:(NSMutableArray *)array{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kWhiteColor;
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(15, 9, self.width - 30, 36)];
        view.layer.masksToBounds = YES;
        view.layer.cornerRadius = view.height / 2;
        view.layer.borderWidth = 1;
        view.layer.borderColor = COLORFROMCODE(0xEEEEEE, 1).CGColor;
        [self addSubview:view];
        NSInteger count = array.count;
        CGFloat width = (view.width - 6)/ count;
        CGFloat height= view.height - 6;
        for (int i = 0; i < count; i++) {
            NSDictionary *dic = array[i];
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.frame = CGRectMake(3 + width * i, 3, width, height);
            button.layer.cornerRadius = height/ 2;
            button.backgroundColor = kWhiteColor;
            [button setTitle:dic[@"CateName"] forState:(UIControlStateNormal)];
            [button setTitleColor:COLORFROMCODE(0xBFBFBF, 1) forState:(UIControlStateNormal)];
            button.titleLabel.font = kFont(13);
            if (i == 0) {
                button.userInteractionEnabled = NO;
                [button setTitleColor:COLORFROMCODE(0x2C2C2C, 1) forState:(UIControlStateNormal)];
                button.backgroundColor = COLORFROMCODE(0xEEEEEE, 1);
            }
            button.tag = 10 + i;
            [view addSubview:button];
        }
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
